package vn.com.servicedirectory.repository.custom;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import vn.com.servicedirectory.model.GovernmentOffice;

public interface GovRegionOfficeReposityCustom {
	@Query("SELECT p From GovernmentOffice p WHERE active=?1")
	Page<GovernmentOffice> findByActive(boolean active,Pageable pageable);

//	@Query("SELECT p From GovernmentOffice p where p.govOfficeRegionName between ?1 and ?2 and active=?3)")
//	Page<GovernmentOffice> findByName(String begin, String end, boolean active,Pageable pageable);
	
	@Query("select p From GovernmentOffice p where substring(p.govOfficeRegionName,1,1) between :begin and :end and (p.active=true or p.active=:active)")
	Page<GovernmentOffice> findByName(@Param(value="begin") String begin, @Param(value = "end") String end, @Param(value="active") boolean active,Pageable pageable);
}
